package mylab.starters.mongodb.model;

import lombok.Data;
import mylab.utils.common.jackson.JacksonUtil;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import jakarta.persistence.Id;
import jakarta.persistence.MappedSuperclass;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @author :  sylar
 * @FileName :  AbstractMongoPO
 * @CreateDate :  2017/11/08
 */
@Data
@MappedSuperclass
@Document
public abstract class MongoEntity implements Serializable {

    @Id
    protected String id;

    @Field("create_time")
    protected LocalDateTime createTime = LocalDateTime.now();

    @Field("update_time")
    protected LocalDateTime updateTime = LocalDateTime.now();

    @Field("deleted")
    protected boolean deleted = false;

    @Override
    public String toString() {
        return JacksonUtil.toJsonString(this);
    }

}
